home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / metamail / richmail / richset.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-10-21  |  4.9 KB  |  175 lines

  1. /*-------------------------------------------------------------------------
  2.  
  3.   richset.h - Handling for different character sets in richtext.
  4.  
  5.   Copyright (c) 1992 Rhys Weatherley
  6.  
  7.   Permission to use, copy, modify, and distribute this material
  8.   for any purpose and without fee is hereby granted, provided
  9.   that the above copyright notice and this permission notice
  10.   appear in all copies, and that the name of Rhys Weatherley not be
  11.   used in advertising or publicity pertaining to this
  12.   material without specific, prior written permission.
  13.   RHYS WEATHERLEY MAKES NO REPRESENTATIONS ABOUT THE ACCURACY OR
  14.   SUITABILITY OF THIS MATERIAL FOR ANY PURPOSE.  IT IS PROVIDED
  15.   "AS IS", WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
  16.  
  17.   Revision History:
  18.   ================
  19.  
  20.    Version  DD/MM/YY  By  Description
  21.    -------  --------  --  --------------------------------------
  22.      1.0    19/06/92  RW  Original Version of richset.h
  23.  
  24.   You may contact the author by:
  25.   =============================
  26.  
  27.    e-mail: rhys@cs.uq.oz.au
  28.      mail: Rhys Weatherley
  29.        5 Horizon Drive
  30.        Jamboree Heights
  31.        Queensland 4074
  32.        Australia
  33.  
  34. -------------------------------------------------------------------------*/
  35.  
  36. #ifndef    __RICHSET_H__
  37. #define    __RICHSET_H__
  38.  
  39. #ifdef    __cplusplus
  40. extern "C" {
  41. #endif
  42.  
  43. /*
  44.  * Define the interface structure for a character set processor.
  45.  * The fields are as follows:
  46.  *
  47.  *    names    - Colon-separated list of character set names.
  48.  *    init    - Initialize the character set processor.
  49.  *    command    - Process a command before the default processing.
  50.  *          Returns non-zero if processed, zero if not.
  51.  *    single    - Should return non-zero for a singleton command.
  52.  *    width    - Get the width in terminal characters of the character.
  53.  *    fold    - Returns non-zero if the character can be folded at.
  54.  *    render    - Render the character through RichtextPutc.
  55.  *    encoding- Enter or leave an encoding. newenc is -1 to leave.
  56.  *
  57.  */
  58. struct    charsetproc
  59.         {
  60.             char *names;
  61.             int (*init) ( /* char *name */ );
  62.             int (*command) ( /* char *token, int negated */ );
  63.             int (*single) ( /* char *token */ );
  64.             int (*width) ( /* RCHAR c */ );
  65.             int (*fold) ( /* RCHAR c */ );
  66.             int (*render) ( /* RCHAR c, void *param */ );
  67.             int (*encoding) ( /* int newenc */ );
  68.         };
  69.  
  70. /*
  71.  * Define some standard character set processors.
  72.  */
  73. extern    struct     charsetproc    usascii_charset;
  74. extern    struct    charsetproc    iso2022_charset;
  75.  
  76. /*
  77.  * Define the information to be kept in the internal buffers
  78.  * about a character.  If "charset" is NULL, it is a control
  79.  * character.
  80.  */
  81. struct    charsetmember
  82.         {
  83.             RCHAR ch;             /* The character itself */
  84.             struct charsetproc *charset; /* Character set of ch */
  85.         };
  86.  
  87. /*
  88.  * Initialise the stack of character set processors, starting with
  89.  * a particular base processor.  The initialisation function of all
  90.  * character set processors is called.
  91.  */
  92. extern    charsetinit    ( /* struct charsetproc *charset, char *name */ );
  93.  
  94. /*
  95.  * Initialise the stack, starting with a character set processor with
  96.  * a particular name.
  97.  */
  98. extern    charsetnameinit    ( /* char *name */ );
  99.  
  100. /*
  101.  * Push a new character set processor onto the stack.
  102.  */
  103. extern    charsetpush    ( /* struct charsetproc *charset */ );
  104.  
  105. /*
  106.  * Pop the top-most character set processor off the stack
  107.  * if it matches the given processor.  Note: the base
  108.  * processor is never popped off.
  109.  */
  110. extern    charsetpop    ( /* struct charsetproc *charset */ );
  111.  
  112. /*
  113.  * See if the character set processor on the top of the stack
  114.  * matches the given processor.
  115.  */
  116. extern    int    charsettop ( /* struct charsetproc *charset */ );
  117.  
  118. /*
  119.  * Set the details for a character set member in the top-most
  120.  * character set.
  121.  */
  122. extern    charmember    ( /* struct charsetmember *member, RCHAR ch */ );
  123.  
  124. /*
  125.  * Set the details for a member of a specific character set.
  126.  */
  127. extern    charmemberspec    ( /* struct charsetmember *member, RCHAR ch,
  128.                  struct charset *charset */ );
  129.  
  130. /*
  131.  * Set the details for a output control code character.
  132.  */
  133. extern    charmemberctrl    ( /* struct charsetmember *member, RCHAR ch */ );
  134.  
  135. /*
  136.  * Determine if the given character is a control code character.
  137.  */
  138. #define    charisctrl(member)    ((member).charset == (struct charsetproc *)0)
  139.  
  140. /*
  141.  * Attempt to process a richtext command by passing it to the
  142.  * "command" function of all character set processors.  Returns
  143.  * zero if the command was not processed.
  144.  */
  145. extern    int    charsetcommand    ( /* char *token, int negated */ );
  146.  
  147. /*
  148.  * Test for an extension singleton command.
  149.  */
  150. extern    int    charsetsingle    ( /* char *token */ );
  151.  
  152. /*
  153.  * Get the width of a particular character.
  154.  */
  155. #define    charmemberwidth(member) \
  156.         ((*((member).charset -> width)) ((member).ch))
  157.  
  158. /*
  159.  * Determine if a character can be folded at.
  160.  */
  161. #define    charmemberfold(member) \
  162.         ((*((member).charset -> fold)) ((member).ch))
  163.  
  164. /*
  165.  * Render a character on an output stream.
  166.  */
  167. #define    charmemberrender(member,param) \
  168.         ((*((member).charset -> render)) ((member).ch,param))
  169.  
  170. #ifdef    __cplusplus
  171. };
  172. #endif
  173.  
  174. #endif    /* __RICHSET_H__ */
  175.